/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PainelMontagem.java
 *
 * Created on 29/09/2010, 14:08:07
 */

package aprendizadosemfio.Montagem.wlan;

import aprendizadosemfio.Montagem.PainelMalha;
import aprendizadosemfio.Telas.FrameGuia;
import aprendizadosemfio.events.MouseEvents;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Toolkit;
import javax.swing.ImageIcon;

/**
 *
 * @author leonardo
 */


public class PainelMontagemWLan extends javax.swing.JFrame  {
    PainelMalha painel = new PainelMalha();;
    ImageIcon img;
    MouseEvents eventos = new MouseEvents();
    
    /** Creates new form PainelMontagem */
    public PainelMontagemWLan()  {
        super("Painel de Montagem - WPAN");
        initComponents();
        
        this.addMouseListener(eventos);
        this.addMouseMotionListener(eventos);
        eventos.setPanel(painel);
        setarFullScreen();
        ajustaAmbiente();
        this.painel.repaint();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        barraBotoes = new javax.swing.JToolBar();
        jButton2 = new javax.swing.JButton();
        laptopButton = new javax.swing.JButton();
        wirelessObj = new javax.swing.JButton();
        pcDesk = new javax.swing.JButton();
        wall = new javax.swing.JButton();
        printer = new javax.swing.JButton();
        Modem = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        BotaoVoltar = new javax.swing.JButton();
        painelPrincipal = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        barraBotoes.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        barraBotoes.setOrientation(1);
        barraBotoes.setRollover(true);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Internet-32.png"))); // NOI18N
        jButton2.setToolTipText("Adiciona representação de internet");
        jButton2.setBorderPainted(false);
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        barraBotoes.add(jButton2);

        laptopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Notebook-32.png"))); // NOI18N
        laptopButton.setToolTipText("Adicione computador notebook");
        laptopButton.setBorderPainted(false);
        laptopButton.setFocusable(false);
        laptopButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        laptopButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        laptopButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                laptopButtonActionPerformed(evt);
            }
        });
        barraBotoes.add(laptopButton);

        wirelessObj.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Wireless Receiver 1 -32x32.png"))); // NOI18N
        wirelessObj.setToolTipText("Adicione receptor wireless");
        wirelessObj.setBorderPainted(false);
        wirelessObj.setFocusable(false);
        wirelessObj.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        wirelessObj.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        wirelessObj.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wirelessObjActionPerformed(evt);
            }
        });
        barraBotoes.add(wirelessObj);

        pcDesk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Computer1_32.png"))); // NOI18N
        pcDesk.setToolTipText("Adicione Desktop");
        pcDesk.setBorderPainted(false);
        pcDesk.setFocusable(false);
        pcDesk.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        pcDesk.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        pcDesk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pcDeskActionPerformed(evt);
            }
        });
        barraBotoes.add(pcDesk);

        wall.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Firewall-32.png"))); // NOI18N
        wall.setToolTipText("Adicione barreira");
        wall.setBorderPainted(false);
        wall.setFocusable(false);
        wall.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        wall.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        wall.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wallActionPerformed(evt);
            }
        });
        barraBotoes.add(wall);

        printer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Printer-32x32.png"))); // NOI18N
        printer.setToolTipText("Adicione impressora");
        printer.setBorderPainted(false);
        printer.setFocusable(false);
        printer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        printer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        printer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                printerActionPerformed(evt);
            }
        });
        barraBotoes.add(printer);

        Modem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/wifi-modem-Vista_32.png"))); // NOI18N
        Modem.setToolTipText("Adicione Modem Wireless");
        Modem.setBorderPainted(false);
        Modem.setFocusable(false);
        Modem.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Modem.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Modem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ModemActionPerformed(evt);
            }
        });
        barraBotoes.add(Modem);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/delete.png"))); // NOI18N
        jButton1.setToolTipText("Deleta algum componente colocado anteriormente");
        jButton1.setBorderPainted(false);
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        barraBotoes.add(jButton1);

        BotaoVoltar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/back.png"))); // NOI18N
        BotaoVoltar.setToolTipText("Retorna ao painel principal");
        BotaoVoltar.setBorderPainted(false);
        BotaoVoltar.setFocusable(false);
        BotaoVoltar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        BotaoVoltar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BotaoVoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotaoVoltarActionPerformed(evt);
            }
        });
        barraBotoes.add(BotaoVoltar);

        javax.swing.GroupLayout painelPrincipalLayout = new javax.swing.GroupLayout(painelPrincipal);
        painelPrincipal.setLayout(painelPrincipalLayout);
        painelPrincipalLayout.setHorizontalGroup(
            painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 397, Short.MAX_VALUE)
        );
        painelPrincipalLayout.setVerticalGroup(
            painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 392, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(barraBotoes, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(painelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(painelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(barraBotoes, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BotaoVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoVoltarActionPerformed
        new FrameGuia().setVisible(true);
        dispose();
    }//GEN-LAST:event_BotaoVoltarActionPerformed

    private void laptopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_laptopButtonActionPerformed
         eventos.setImg(new ImageIcon(getClass().getResource("/resource/Notebook-64.png")));
         
    }//GEN-LAST:event_laptopButtonActionPerformed

    private void wirelessObjActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wirelessObjActionPerformed
        eventos.setImg(new ImageIcon(getClass().getResource("/resource/Wireless Receiver 1 -64x64.png")));
    }//GEN-LAST:event_wirelessObjActionPerformed

    private void pcDeskActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pcDeskActionPerformed
        eventos.setImg(new ImageIcon(getClass().getResource("/resource/Computer1_64.png")));
    }//GEN-LAST:event_pcDeskActionPerformed

    private void wallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wallActionPerformed
        ImageIcon imag = new ImageIcon(getClass().getResource("/resource/Firewall-64.png"));
        imag.setDescription("muro");
        eventos.setImg(imag);
    }//GEN-LAST:event_wallActionPerformed

    private void printerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printerActionPerformed
        ImageIcon imag = new ImageIcon(getClass().getResource("/resource/Printer-64x64.png"));
        imag.setDescription("impressora");
        eventos.setImg(imag);
    }//GEN-LAST:event_printerActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        ImageIcon imag = new ImageIcon(getClass().getResource("/resource/delete.png"));
        imag.setDescription("delete");
        eventos.setImg(imag);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void ModemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ModemActionPerformed
        eventos.setImg(new ImageIcon(getClass().getResource("/resource/modem_64.png")));
    }//GEN-LAST:event_ModemActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        eventos.setImg(new ImageIcon(getClass().getResource("/resource/Internet-64.png")));
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PainelMontagemWLan().setVisible(true);
            }
        });
    }

    public void ajustaAmbiente() {

        painel.setSize(this.getWidth()-barraBotoes.getWidth(),this.getHeight());
        painel.setLocation(0, 0);
        painelPrincipal.add(painel);
        this.repaint();

    }

    public void setarFullScreen() {
        Insets in = Toolkit.getDefaultToolkit().getScreenInsets(this.getGraphicsConfiguration()); //recupera aspectos gráficos do ambiente

        Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); //recupera dimensão do ambiente

        int width = d.width - (in.left + in.top);
        int height = d.height - (in.top + in.bottom);
        setSize(width, height); //calcula dimensões de tela cheia e atribui ao programa
        setLocation(in.left, in.top); //posiciona frame em tela cheia para evitar que haja perda das laterais
}


  

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotaoVoltar;
    private javax.swing.JButton Modem;
    private javax.swing.JToolBar barraBotoes;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton laptopButton;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JPanel painelPrincipal;
    private javax.swing.JButton pcDesk;
    private javax.swing.JButton printer;
    private javax.swing.JButton wall;
    private javax.swing.JButton wirelessObj;
    // End of variables declaration//GEN-END:variables

  

   


}
